package com.xzm.project.ui.activity;

import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.Button;
import android.widget.LinearLayout;

import com.orhanobut.logger.Logger;
import com.xzm.project.R;
import com.xzm.project.ui.widget.MyCanvas;

/**
 * author : xuzongmeng
 * date   : 2019/9/2
 * desc   : 描述
 */
public class MyCanvasActivity extends BaseActivity {
    private Button btnDrawLine;
    private Button btnDrawLines;
    private MyCanvas myCanvas;
    private LinearLayout rootContainer;

    @Override
    protected int getLayoutID() {
        return R.layout.activity_my_canvas;
    }
    @Override
    protected void initView(Bundle savedInstanceState) {
        myCanvas = findViewById(R.id.myCanvas);
        btnDrawLine = findViewById(R.id.btnDrawLine);
        btnDrawLines = findViewById(R.id.btnDrawLines);
        rootContainer = findViewById(R.id.rootContainer);

    }
    @Override
    protected void initListener() {
//        btnDrawLine.setOnClickListener(v -> myCanvas.drawLine());
//        btnDrawLines.setOnClickListener(v -> myCanvas.drawPoint());
//        rootContainer.getClipChildren()
    }


    @Override
    public void initData() {
        int childCount = rootContainer.getChildCount();
        Logger.d(childCount);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction()==MotionEvent.ACTION_MOVE){
            myCanvas.bitmapX = event.getX();
            myCanvas.bitmapY = event.getY();
            myCanvas.invalidate();
        }
        return  super.onTouchEvent(event);
    }
}
